package com.serviceImpl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dao.RoleDao;
import com.domain.Function;
import com.domain.Role;
import com.service.RoleService;

@Service(value="roleService")
@Transactional
public class RoleServiceImpl implements RoleService{
	@Resource(name="roleDao")
	private RoleDao roleDao;

	@Override
	public List<Role> findAllRole() {
		return roleDao.findAll();
	}

	@Override
	public void saveRole(Role model, String functionIds) {
		roleDao.save(model);
		String[] ids = functionIds.split(",");
		System.out.println(ids.toString());
		for (String id : ids) {
			Function function = new Function();
			function.setId(id);
			model.getFunctions().add(function);
		}
		
	}
}
